#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
typedef struct BinaryTreeNode
{
    char data;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;
BTNode* preordercreate(char* arr, int* i)
{
    if (arr[(*i)] == '#')
    {
        (*i)++;
        return NULL;
    }
    BTNode* ret = (BTNode*)malloc(sizeof(BTNode));
    ret->data = arr[(*i)++];
    ret->left = preordercreate(arr, i);
    ret->right = preordercreate(arr, i);
    return ret;
}
void treeinorder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    treeinorder(root->left);
    printf("%c ", root->data);
    treeinorder(root->right);
}
int main() {
    char arr[100] = { 0 };
    scanf("%s", arr);
    int i = 0;
    BTNode* tree = preordercreate(arr, &i);
    treeinorder(tree);
    return 0;
}